package com.lft.com.oilgas.controller;


import com.baomidou.mybatisplus.extension.api.R;
import com.lft.com.oilgas.entity.IdCard;
import com.lft.com.oilgas.service.impl.IdCardServiceImpl;
import com.lft.com.oilgas.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author tyqw
 * @since 2024-09-10
 */
@Transactional
@RestController
@CrossOrigin
@RestControllerAdvice
@RequestMapping("/util/id-card")
public class IdCardController {
    //处理异常
    @ExceptionHandler(Exception.class)
    private Result yichang(Exception e) {
        //noinspection CallToPrintStackTrace
        e.printStackTrace();
        return new Result(false, "服务器异常，请稍后重试");
    }

    @Autowired
    private IdCardServiceImpl idCardService;
//新增或修改
    @RequestMapping("/zengorgai")
    private Result zengorgai(@RequestBody IdCard idCard) {
        System.out.println(idCard);
        idCardService.InsertOrUpdate(idCard);
        return new Result(true, null);
    }
//查询详情
    @RequestMapping("/xianqing/{id}")
    private Result selectOne(@PathVariable("id") Integer id){
        IdCard idCard = idCardService.selectOne(id);
        return new Result(true,idCard);
    }
}
